import com.typesafe.sbt.SbtStartScript

version in ThisBuild := "0.0.1-SNAPSHOT"

organization in ThisBuild := "jxcontent.eicp.net"

scalaVersion in ThisBuild := "2.11.2"

resolvers in ThisBuild ++= Seq(
  "snapshots" at "https://oss.sonatype.org/content/repositories/snapshots",
  "staging" at "http://oss.sonatype.org/content/repositories/staging",
  "releases" at "http://oss.sonatype.org/content/repositories/releases",
  "oschina" at "http://maven.oschina.net/content/groups/public"
)

scalacOptions in ThisBuild ++= Seq("-feature")

scalacOptions in ThisBuild ++= Seq("-deprecation")

scalacOptions in ThisBuild ++= Seq("-Xlog-free-terms")

unmanagedBase in ThisBuild <<= baseDirectory { base => base / "lib" }

EclipseKeys.withSource in ThisBuild := true

EclipseKeys.withJavadoc in ThisBuild := true

EclipseKeys.skipParents in ThisBuild := false

EclipseKeys.withBundledScalaContainers in ThisBuild := true

EclipseKeys.executionEnvironment in ThisBuild := Some(EclipseExecutionEnvironment.JavaSE18)

lazy val jxcontent = Project(
  id = "jxcontent",
  base = file("."),
  settings = Defaults.coreDefaultSettings ++ SbtStartScript.startScriptForClassesSettings
) settings (
  name := "jxcontent"
) aggregate (core, admin, doc, template, cms, web)

lazy val core_macro = Project(
  id = "core-macro",
  base = file("jxcontent-core/jxcontent-core-macro"),
  settings = Defaults.coreDefaultSettings ++ SbtStartScript.startScriptForClassesSettings
) settings (
  name := "jxcontent-core-macro",
  libraryDependencies ++= {
    val liftVersion = "2.6-M4"
    Seq(
      "org.scala-lang" % "scala-reflect" % "2.11.1"
    )
  }
)

lazy val core = Project(
	id = "core",
	base = file("jxcontent-core"),
	settings = Defaults.coreDefaultSettings ++ SbtStartScript.startScriptForClassesSettings
) settings (
  name := "jxcontent-core",
  libraryDependencies ++= {
    val liftVersion = "2.6-RC1"
    Seq(
      "ch.qos.logback" % "logback-classic" % "1.1.2" % "compile",
      "net.liftweb" %% "lift-webkit" % liftVersion % "compile",
      "net.liftweb" %% "lift-mapper" % liftVersion % "compile",
      "net.liftmodules" %% "lift-jquery-module_2.6" % "2.8" % "compile",
      "net.liftweb" %% "lift-mongodb-record" % liftVersion % "compile",
      "org.mongodb" %% "casbah" % "2.7.3" % "compile",
      "org.specs2" %% "specs2" % "2.4.1" % "test"
    )
  }
) aggregate core_macro dependsOn core_macro

lazy val admin = Project(
	id = "admin",
	base = file("jxcontent-admin"),
	settings = Defaults.coreDefaultSettings ++ SbtStartScript.startScriptForClassesSettings
) settings (
  name := "jxcontent-admin"
) dependsOn core

lazy val doc = Project(
	id = "doc",
	base = file("jxcontent-doc"),
	settings = Defaults.coreDefaultSettings ++ SbtStartScript.startScriptForClassesSettings
) settings (
  name := "jxcontent-doc"
) dependsOn admin

lazy val template = Project(
	id = "template",
	base = file("jxcontent-template"),
	settings = Defaults.coreDefaultSettings ++ SbtStartScript.startScriptForClassesSettings
) settings (
  name := "jxcontent-template"
) dependsOn doc

lazy val cms = Project(
	id = "cms",
	base = file("jxcontent-cms"),
	settings = Defaults.coreDefaultSettings ++ SbtStartScript.startScriptForClassesSettings
) settings (
  name := "jxcontent-cms"
) dependsOn doc

lazy val web = Project(
	id = "web",
	base = file("jxcontent-web"),
	settings = Defaults.coreDefaultSettings ++ jetty(
    port = 1314,
    libs = {
      val jettyVersion = "9.2.2.v20140723"
      Seq(
        "org.eclipse.jetty" % "jetty-runner" % jettyVersion % "container" intransitive()
      )
    }
  ) ++ SbtStartScript.startScriptForClassesSettings
) settings (
  name := "jxcontent-web",
  unmanagedResourceDirectories in Test <+= (baseDirectory) { _ / "src/main/webapp" },
  javaOptions in container ++= Seq("-noverify"),
  javaOptions in container ++= Seq("-Xms512M"),
  javaOptions in container ++= Seq("-Xmx512M"),
  javaOptions in container ++= Seq("-Xss1M"),
  javaOptions in container ++= Seq("-XX:+UseConcMarkSweepGC"),
  javaOptions in container ++= Seq("-XX:+CMSClassUnloadingEnabled")
)  dependsOn (template, cms)